#include <iostream>
#include <vector>
#include <algorithm>
#include<queue>
#include <string>
#include<stack>
using namespace std;

class Solution {
public:
    string makeGood(string s) {
        stack<char> sp;
        for(int i=0;i<s.size();i++){
            char ch = s[i];
            if(sp.empty()){
                sp.push(ch);
            } else {
                char ch2 = sp.top();
                if(ch2+' '==ch || ch2-' '==ch){
                    sp.pop();
                } else {
                    sp.push(ch);
                }
            }
        }
        string ans;
        while(!sp.empty()){
            ans.push_back(sp.top());
            sp.pop();
        }
        string ans2;
        for(int i=ans.size()-1;i>=0;i--){
            ans2.push_back(ans[i]);
        }
        return ans2;
    }
};

int main()
{
    char a ='A',b='a';
    Solution solution;
    string s = "abBAcC";
    cout<<solution.makeGood(s)<<endl;
    s = "s";
    cout<<solution.makeGood(s)<<endl;
    s = "leEeetcode";
    cout<<solution.makeGood(s)<<endl;
    return 0;
}